
{% extends 'authuser/base.html' %}
{% block content %}

<script type="text/javascript">
	next="{{next |default:'/'}}"
	regist_url='{{regist_url}}'
	
	meta={
		errors:{},
		row:{
			username:'',
			password:'',
		},
		heads:[
			{name:'username',label:'用户名',type:'linetext',autofocus:true,placeholder:'username'},
			{name:'password',label:'密码',type:'password',placeholder:'your password',},
		]
	}

	$(function () {
		new Vue({
			el:'#content',
			data:{
				meta:meta,
				regist_url:regist_url
			},
			methods:{
				submit_info:function () {
					var models=this.meta.row
					var post_data={
						do_login:{username:models.username,password:models.password}
					}
					var self=this;
					$.post('',JSON.stringify(post_data),function (data) {
						if(data.do_login.errors){
							update_vue_obj(self.meta.errors,data.do_login.errors)
						}else{
							location=next;
						}
						//is_valid(data.do_login,self.meta.errors,function () {
						//	location=next;
						//})
			
					})
				}
			}
		})
	})

</script>

<div class='container' id='content'>
	<div ng-controller='content'>
		<form name="logForm" ng-submit='submit_func(logForm.$valid)' class='form-signin' novalidate>
			<h2 class='form-signin-heading'>欢迎登陆</h2>
			<field name='username' :kw='meta'></field>
			<field name='password' :kw='meta'></field>
	
			<button name="test" type="button" value="val" @click='submit_info()'>登陆</button>
	
			<div style='text-align: right;padding-top:10px;'>
				<a :href="regist_url" >注册</a>
			</div>

		</form>

</div>

</div>
<style type="text/css">
	.form-signin{
		max-width:330px;
		padding: 15px;
		margin: 0 auto;
	}
	input{
		margin-bottom:3px;
	}
</style>

{% endblock %}